﻿using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;

namespace EasyDDD.Domain.User
{
    /// <summary>
    /// 用户与登录相关联
    /// </summary>
    [PrimaryKey(nameof(UserId))]
    public class ApplicationUserLogin
    {
        [JsonConstructor]
        public ApplicationUserLogin() { }

        /// <summary>
        /// Gets or sets the primary key of the user associated with this login.
        /// </summary>
        [ForeignKey(nameof(ApplicationUser))]
        public virtual Guid UserId { get; set; } = default!;
        public virtual ApplicationUser ApplicationUser { get; set; } = default!;


        /// <summary>
        /// Gets or sets the login provider for the login (e.g. facebook, google)
        /// </summary>
        [StringLength(128)]
        public virtual string LoginProvider { get; set; } = default!;

        /// <summary>
        /// Gets or sets the unique provider identifier for this login.
        /// </summary>
        [StringLength(512)]
        public virtual string ProviderKey { get; set; } = default!;

        /// <summary>
        /// Gets or sets the friendly name used in a UI for this login.
        /// </summary>
        [StringLength(128)]
        public virtual string ProviderDisplayName { get; set; } = string.Empty;
    }
}

